package com.fr.report.highlight;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.cellElement.CellPageAttr;
import com.fr.report.script.Calculator;

public class PageHighlightAction extends AbstractHighlightAction
{
  public static final int NO_PAGE = 0;
  public static final int AFTER_ROW = 1;
  public static final int BEFORE_ROW = 2;
  public static final int AFTER_COL = 3;
  public static final int BEFORE_COL = 4;
  private int page = 0;

  public PageHighlightAction()
  {
  }

  public PageHighlightAction(int paramInt)
  {
    this.page = paramInt;
  }

  public int getPage()
  {
    return this.page;
  }

  public void setPage(int paramInt)
  {
    this.page = paramInt;
  }

  public void action(CellElement paramCellElement, Calculator paramCalculator)
  {
    CellPageAttr localCellPageAttr = paramCellElement.getCellPageAttr();
    if (localCellPageAttr == null)
    {
      localCellPageAttr = new CellPageAttr();
      paramCellElement.setCellPageAttr(localCellPageAttr);
    }
    else
    {
      try
      {
        localCellPageAttr = (CellPageAttr)localCellPageAttr.clone();
      }
      catch (CloneNotSupportedException localCloneNotSupportedException)
      {
      }
      paramCellElement.setCellPageAttr(localCellPageAttr);
    }
    switch (this.page)
    {
    case 1:
      localCellPageAttr.setPageAfterRow(true);
      break;
    case 2:
      localCellPageAttr.setPageBeforeRow(true);
      break;
    case 3:
      localCellPageAttr.setPageAfterColumn(true);
      break;
    case 4:
      localCellPageAttr.setPageBeforeColumn(true);
      break;
    case 0:
      localCellPageAttr.setPageAfterRow(false);
      localCellPageAttr.setPageBeforeRow(false);
      localCellPageAttr.setPageAfterColumn(false);
      localCellPageAttr.setPageBeforeColumn(false);
    }
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("P".equals(paramXMLableReader.getTagName())))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("i")) != null)
        setPage(Integer.parseInt(str));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if ((this.page >= 0) && (this.page <= 4))
      paramXMLPrintWriter.startTAG("P").attr("i", this.page).end();
  }
}